package net.lab1024.sa.ai.stream.config;

import net.lab1024.sa.base.common.domain.DataScopePlugin;
import org.apache.ibatis.plugin.Intercepts;
import org.apache.ibatis.plugin.Invocation;
import org.apache.ibatis.plugin.Plugin;
import org.apache.ibatis.plugin.Signature;
import org.apache.ibatis.executor.Executor;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.session.ResultHandler;
import org.apache.ibatis.session.RowBounds;
import org.springframework.stereotype.Component;

import java.util.Properties;

/**
 * sa-ai-stream 模块的数据范围插件实现
 * 由于 sa-ai-stream 不需要复杂的数据权限控制，这里提供一个简单的实现
 *
 * @Author 1024创新实验室
 * @Date 2025-07-18
 * @Copyright <a href="https://1024lab.net">1024创新实验室</a>
 */
@Intercepts({
    @Signature(type = Executor.class, method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class})
})
@Component
public class DataScopePluginConfig extends DataScopePlugin {

    @Override
    public Object intercept(Invocation invocation) throws Throwable {
        // sa-ai-stream 模块不需要数据权限控制，直接执行原方法
        return invocation.proceed();
    }

    @Override
    public Object plugin(Object target) {
        return Plugin.wrap(target, this);
    }

    @Override
    public void setProperties(Properties properties) {
        // 不需要设置属性
    }
} 